<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>应急信息发布项目审核查看</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link href="../../layui/css/iconfont/iconfont.css" rel="stylesheet" type="text/css">
    <link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
    <link href="../../css/style.css" rel="stylesheet" type="text/css">
    <script src="../../layui/layui.js"></script>
    <script src="../../js/jquery-1.8.3.js"></script>
    <script src="../../js/util.js"></script>
    <script>
        layui.use(['form', 'jquery', 'element', 'laydate', 'layer'], function () {
            var form = layui.form;
            var $ = layui.$;
            var laydate = layui.laydate;
            var layer = layui.layer;
            var mgrId = getUrlParam("mgrId");
            var cityId = getUrlParam("cityId");
            laydate.render({
                elem: '#startTime'
            });
            laydate.render({
                elem: '#endTime'
            });
            $('#yes').on('click', function () {
                var param = {
                    mgrId: mgrId,
                    state: 2,
                    remark: "通过"
                };
                var url = '/templateCheck/check';
                $.ajax({
                    type: 'post',
                    async: false,
                    url: url,
                    data: param,
                    beforeSend: function () {
                        if ($("#remark").val() == "") {
                            $("#remark").val("通过");
                        }
                        loading = layer.load(0, {shade: false});
                    },
                    success: function (json) { 						
    						 layer.close(loading);
                        var data = json.data;
                        if (json.code == 0) {
                            layui.use('layer', function () {
                                layer.msg('审核成功，点击确定按钮进行项目开启', {
                                    time: 0 //不自动关闭
                                    , btn: ['确定']
                                    , yes: function (index) {
                                        layer.close(index);
                                        var mgrIdState="";;
                                        if(json.count==0){
                                            mgrIdState=" 开启 ";
                                        }else if(json.count==1){
                                            mgrIdState=" 暂停 ";
                                        }else if(json.count==2){
                                            mgrIdState=" 关闭 ";
                                        }else if(json.count==3){
                                            mgrIdState=" 配置中 ";
                                        }
                                        //修改项目状态 count
                                        layer.confirm('目前该项目状态为'+mgrIdState+'，是否需要开启项目？', {btn: ['开启', '取消'],icon: 3, title: '提示'}, function (index) {
				                            var turl = "/mgrTemplate/modifyMgrState";
				                            var tparam = {
				                                id: mgrId,
				                                cityId:cityId,
				                                mgrState: 0
				                            };
				                            $.ajax({
				                                type: 'post',
				                                data: tparam,
				                                url: turl,
				                                beforeSend: function () {
				                                },
				                                success: function (tjson) {
				                                    if (tjson.code == 0) {
				                                        layer.confirm('修改成功', {
				                                            btn: ['确定'] //按钮
				                                        }, function () {   															
    														location.href = "smsTemplateCheckManage.html";
    														//变更同步
    														var turl = "/SmsChange/findChangeByMgrId";
    														var tparam = {
    															mgrId : mgrId
    														};
    														$.ajax({
    															type : 'post',
    															data : tparam,
    															url : turl,
    															success : function(tjson) {
    																console.info(tjson);
    															}
    														})
    
    													});
				                                    }else {
				                                       layer.msg(tjson.data.msg);
				                                    }
				                                },
				                                complete: function () {
				                                }
				                            });
				                        },  function (index) {
				                            location.href = "smsTemplateCheckManage.html";
				                        });
                                    }
                                });
                            });
                        } else {
                            layer.msg(json.msg);
                        }
                    }
                    ,
                    error: function (data) {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
            });

            $('#no').on('click', function () {
                var param = {
                    mgrId: mgrId,
                    state: 3,
                    remark: $("#remark").val()
                };
                var url = '/templateCheck/check';
                $.ajax({
                    type: 'post',
                    async: false,
                    url: url,
                    data: param,
                    beforeSend: function () {
                        if ($("#remark").val() == "") {
                            layer.msg("审核说明不能为空");
                            return false;
                        }
                        loading = layer.load(0, {shade: false});
                    },
                    success: function (json) {
                        layer.close(loading);
                        var data = json.data;
                        if (json.code == 0) {
                            layui.use('layer', function () {
                                layer.msg('审核成功，点击确定按钮返回审核管理界面', {
                                    time: 0 //不自动关闭
                                    , btn: ['确定']
                                    , yes: function (index) {
                                    	var turl = "/busi/modify";
				                            var tparam = {
				                                id: mgrId,
				                                state: 2
				                            };
				                            $.ajax({
				                                type: 'post',
				                                data: tparam,
				                                url: turl,
				                                beforeSend: function () {
				                                },
				                                success: function (tjson) {
				                                    if (tjson.code == 0) {
				                                       location.href = "smsTemplateCheckManage.html";
				                                    }
				                                    else {
				                                       layer.msg(tjson.data.msg);
				                                    }
				                                },
				                                complete: function () {
				                                }
				                            });
                                        layer.close(index);
                                        location.href = "smsTemplateCheckManage.html";
    									//变更同步
    									var turl = "/SmsChange/findChangeByMgrId";
    									var tparam = {
    										mgrId : mgrId
    									};
    									$.ajax({
    										type : 'post',
    										data : tparam,
    										url : turl,
    										success : function(json) {
    											console.info(json);
    										}
    									})
    								}
                                });
                            });
                        } else {
                            layer.msg(json.msg);
    					}
    				},
                    error: function (data) {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
            });

            //页面数据初始化
            $(document).ready(function () {
                var url = '/mgrTemplate/findMgrTemplateByMgrId';
                var param = {
                    mgrId: mgrId
                };
                $.ajax({
                    type: 'post',
                    async: false,
                    url: url,
                    data: param,
                    beforeSend: function () {
                        loading = layer.load(0, {shade: false});
                    },
                    success: function (json) {
                        layer.close(loading);
                        var data = json.data;
                        //$("#startTime").val(data.startDate);
                        //$("#endTime").val(data.endDate);
						$('#content').val(data.content);
						if(data.countyName ==null){$('#cityName').val(data.cityName );}
						else{$('#cityName').val(data.cityName + data.countyName);}
						//$('#countyName').val(data.countyName);
						$('#mgrName').val(data.name);						
                    }
                    ,
                    error: function (data) {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
            });
        });
    </script>
</head>
<body>
<div class="layui-html-limit">
    <div class="layui-content-body">
        <div class="scroll-box">
            <div class="breadcrumb-box">
              <span class="layui-breadcrumb" lay-separator="|">
     <a href="javascript:returnIndex2()">首页&nbsp;</a>
     <a href="#">&nbsp;项目审核管理&nbsp;</a>
     <a href="#">&nbsp;短信项目审核&nbsp;</a>
     <a href="#"> &nbsp;短信项目审核查看&nbsp; </a>
</span>
         </div>
         <div class="content-box">
         <div class="layui-form layui-form-pane" action="">
                <div class="layui-form-item">
                        <div class="layui-block" pane="">
                            <label class="layui-form-label">归属地</label>
                            <div class="layui-input-block">
                                <input type="text" style="width:auto"
                                       id="cityName" autocomplete="off" class="layui-input" disabled>
                            </div>
                        </div>
                    </div>
                <div class="layui-form-item">
                        <div class="layui-block" pane="">
                            <label class="layui-form-label">项目名称</label>
                            <div class="layui-input-block">
                                <input type="text" style="width:auto"
                                       id="mgrName" autocomplete="off" class="layui-input" disabled>
                            </div>
                        </div>
                    </div>
							<div class="layui-form-item">
								<div class="layui-block" pane="">
									<label class="layui-form-label">短信内容</label>
									<div class="layui-input-block">
										<textarea placeholder="请输入内容" class="layui-textarea"
											style="width: 30%" id="content" disabled></textarea>
									</div>
								</div>
							</div>

							<!--  <div class="layui-form-item">
                        <div class="layui-block">
                            <label class="layui-form-label" style="width: auto">发送起止时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="date" id="startTime" autocomplete="off" class="layui-input"
                                       disabled>
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline">
                                <input type="text" name="date" id="endTime" autocomplete="off" class="layui-input"
                                       disabled>
                            </div>
                        </div>
                    </div> -->
							<div class="layui-form-item">
								<label class="layui-form-label">审核说明</label>
								<div class="layui-input-block">
									<textarea placeholder="请输入内容" class="layui-textarea"
										style="width: 30%" id="remark"></textarea>
								</div>
							</div>
							<div class="layui-form-item">
								<button class="layui-btn layui-btn-normal" id="yes">审核通过</button>
								<button class="layui-btn layui-btn-danger" id="no">审核不通过</button>
							</div>
						</div>

					</div>
        </div>
    </div>
</div>
</div>

</body>
</html>